package com.settlement.system.rules;

import com.settlement.system.model.entity.SysAudit;
import com.settlement.system.model.entity.SysAuditRule;

import java.math.BigDecimal;

/**
 * "7、已退款未发货
 * （未发货已收款已退款）"
 */
public class NotSendHasReceiveHasRefundRuler implements CommonRuler{
    @Override
    public boolean check(SysAudit sysAudit, SysAuditRule auditRule) {
        // "应收账款余额=0
        //且收款金额＞0
        //且退款金额+保证金退款金额<0
        //且发货金额=0
        //且收款金额+退款金额+保证金退款金额=0"
        return BigDecimal.ZERO.compareTo(sysAudit.getReceiveBillAmount()) == 0 &&
                sysAudit.getReceiveAmount().compareTo(BigDecimal.ZERO) > 0 &&
                sysAudit.getRefundAmount().add(sysAudit.getDepositAmount()).compareTo(BigDecimal.ZERO) < 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getSendAmount()) == 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getReceiveAmount().add(sysAudit.getRefundAmount()).add(sysAudit.getDepositAmount())) == 0;
    }
}
